package com.sengled.cloud.biz.union.mgt.dao.sys;


import com.sengled.cloud.biz.union.mgt.model.po.AccountRole;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface AccountRoleDao {
    int deleteByPrimaryKey(Long id);

    int insert(AccountRole record);

    int insertSelective(AccountRole record);

    AccountRole selectByPrimaryKey(Long id);

    @Select("select id as id,user_account_id as userAccountId,role_id as roleId from account_role where user_account_id = #{id} and enable_mark = 1 ")
    List<AccountRole> selectByUserAccountKey(Long id);

    int updateByPrimaryKeySelective(AccountRole record);

    int updateByPrimaryKey(AccountRole record);

    @Select("select ua.account_name from account_role ar,user_account ua where ua.id = ar.user_account_id and ar.role_id = #{roleId} ")
    List<String> selectAccountNameByRoleId(@Param("roleId") Long roleId);

    @Delete(" delete from account_role where role_id = #{roleId} ")
    Integer deleteByRoleId(@Param("roleId") Long roleId);

    @Update("update account_role set enable_mark = #{enableMark} where role_id = #{roleId} ")
    int updateEnableMarkByRoleId(@Param("roleId") Long roleId,@Param("enableMark") Integer enableMark);

    @Update("update account_role set seal_mark = 1 where role_id = #{roleId} ")
    int updateSealMarkByRoleId(@Param("roleId") Long roleId);
}